package exercises.leetcode;

import java.util.TreeMap;

/**
 * <a href="">
 * </a>
 *
 * <p><span color="#87CEEB">描述:</span>
 *
 * @author or2
 * @date 2021年11月14日 时间: 10:11
 */
public class No5912$65$2 {
    public int[] maximumBeauty(int[][] items, int[] queries) {
        var res = new int[queries.length];

        var tree = new TreeMap<Integer, Integer>();
        for (int[] item : items) {
            int price = item[0], beauty = item[1];
            if (tree.isEmpty()) tree.put(price, beauty);

            var pre = tree.floorEntry(price);
            if (pre != null) {
                if (pre.getValue() < beauty) tree.remove(pre.getKey());
            }
        }

        return res;
    }
}
